{% extends base.html %}

{% block body %}

<div class="col-md-12 card">

    <h3 class="card-title btn-line-height">
        <span>代码统计</span>
        <div class="float-right">
            <a class="btn btn-default" href="javascript:history.back();">返回</a>
        </div>
    </h3>

    {% include "mod_fs_path.html" %}
<!-- POST会被GET参数覆盖 -->
<form method="GET">
    <input type="text" name="count" class="hide" value="on">
    <input type="text" name="path" class="hide" value="{{path}}">
    <table class="no-border-table">
        <tr>
            <td>包含内容</td>
            <td>
                <textarea cols="100" name="filter_text">{{filter_text}}</textarea>
            </td>
        </tr>
        <tr>
            <td>黑名单</td>
            <td>
                <div class="input-help-text" style="color: red;">*匹配任意字符，比如lib/*, 一行一个规则</div>
                <textarea name="blacklist" cols=100 autoheight>{{blacklist}}</textarea>
            </td>
        <tr>
            <td>类型</td>
            <td>
                <select name="type">
                    {% for _type in typedict %}
                        <option value="{{_type}}" {% if type == _type %} selected {% end %}>{{_type}}</option>
                    {% end %}
                </select>
            </td>
        </tr>
        <tr>
            <td>包含子目录</td>
            <td><input type="checkbox" name="recursive" {% if recursive == "on" %} checked {% end %}/></td>
        </tr>
        <tr>
            <td>行数排序</td>
            <td><input type="checkbox" name="lines_sort" default-value="{{lines_sort}}"/></td>
        </tr>
    </table>
    <button>统计</button>
</form>
</div>

<div class="card">
    {% if len(line_infos) > 0 %}
    <div>文件数 {{len(line_infos)-1}}</br>
    总行数 {{line_infos[0].lines}}</br>
    有效行数 {{line_infos[0].validlines}}</br>
    空白行数 {{line_infos[0].blanklines}}</br>
    </div>
    {% end %}

    <table class="table">
    <tr>
    <th>编号</th>
    <th>文件名</th>
    <th>行数</th>
    <th>有效行数</th>
    <th>空白行数</th>
    </tr>

    {% for index, info in enumerate(line_infos) %}

        <tr>
            <td>{{index+1}}</td>
            <td><a target="_blank" href="/code/edit?path={{info.fname}}">{{info.display_name}}</a></td>
            <td>{{info.lines}}</td>
            <td>{{info.validlines}}</td>
            <td>{{info.blanklines}}</td>
        </tr>

    {% end %}
    </table>
</div>

{% end %}